package com.pur.zsms.quotation.web;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.cglib.beans.BeanCopier;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.pur.zsms.accountmanage.vo.AccountVo;
import com.pur.zsms.check.vo.CheckVo;
import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.common.util.ExcelReader;
import com.pur.zsms.common.util.FileUtill;
import com.pur.zsms.common.util.PubFun;
import com.pur.zsms.documentsmanage.vo.DomVo;
import com.pur.zsms.lockmanage.service.ILockTransService;
import com.pur.zsms.matermanage.mater.vo.MaterVo;
import com.pur.zsms.ordercustommanage.po.OrderSupplierMaterPo;
import com.pur.zsms.ordercustommanage.vo.ExcelVo;
import com.pur.zsms.ordercustommanage.vo.OrderCustVo;
import com.pur.zsms.ordercustommanage.vo.SelectFoodVo;
import com.pur.zsms.pmsnmanage.menu.po.MenuPo;
import com.pur.zsms.pmsnmanage.role.vo.RoleVo;
import com.pur.zsms.pmsnmanage.user.po.UserPo;
import com.pur.zsms.pmsnmanage.user.po.UserRolePo;
import com.pur.zsms.pmsnmanage.user.service.IUserService;
import com.pur.zsms.pmsnmanage.user.vo.UserVo;
import com.pur.zsms.pmsnmanage.user.web.UserControllor;
import com.pur.zsms.quotation.po.QuotationCompanyPeriodPo;
import com.pur.zsms.quotation.po.QuotationCompanyPeriodSubPo;
import com.pur.zsms.quotation.po.QuotationPo;
import com.pur.zsms.quotation.po.QuotationSubPo;
import com.pur.zsms.quotation.service.IQuotationService;
import com.pur.zsms.quotation.vo.QuotationCompanyPeriodExcelVo;
import com.pur.zsms.quotation.vo.QuotationCompanyPeriodSubVo;
import com.pur.zsms.quotation.vo.QuotationCompanyPeriodVo;
import com.pur.zsms.quotation.vo.QuotationVo;
import com.pur.zsms.shopmanage.vo.ShopVo;
import com.pur.zsms.supplier.po.ShopSupplierTypePo;
import com.pur.zsms.supplier.po.SupplierPo;
import com.pur.zsms.supplier.service.ISupplierService;
import com.pur.zsms.supplier.vo.ShopSupplierVo;
import com.pur.zsms.supplier.vo.SupplierDistributeVo;
import com.pur.zsms.supplier.vo.SupplierOrderCustVo;
import com.pur.zsms.supplier.vo.SupplierQualificationVo;
import com.pur.zsms.supplier.vo.SupplierVo;
import com.pur.zsms.systemsetting.datadictionary.po.Code;
import com.pur.zsms.systemsetting.datadictionary.vo.CodeVo;
import com.pur.zsms.timecontrol.service.ITimeControlService;

/**
 * 公司报价
 * 
 * @author yuxin
 * 
 */
@Controller
@RequestMapping(value = "/quotationCompany")
public class QuotationCompanyController {
	@SuppressWarnings("unused")
	private static final Logger log = LoggerFactory.getLogger(QuotationCompanyController.class);
	protected int page = 1;

	protected int pageSize = 15;

	PaginationSupport pageList;

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	@Resource(name = "supplierService")
	private ISupplierService supplierService;

	@Resource(name = "timeControlService")
	private ITimeControlService timeControlService;

	@Resource(name = "userService")
	private IUserService userService;

	@Resource(name = "lockTransService")
	private ILockTransService lockTransService;

	@Resource(name = "quotationService")
	private IQuotationService quotationService;

	@RequestMapping(value = "/companyPeriodList.do", method = { RequestMethod.POST })
	@ResponseBody
	public String companyPeriodList(@RequestParam(required = false) String page, @RequestParam(required = false) String rows,
			QuotationCompanyPeriodVo quotationCompanyPeriodVo, HttpSession session) throws GenericException {
		JSONObject json = new JSONObject();
		if (page == null || page.equals(""))
			page = "1";
		if (rows == null || rows.equals(""))
			rows = "10";

		UserPo userInfo = (UserPo) session.getAttribute("user");
		int supId = supplierService.getSupIdByUserId(userInfo.getUserId());
		quotationCompanyPeriodVo.setSupId(supId);
		PageController pageController = new PageController(Integer.parseInt(page), Integer.parseInt(rows));
		this.pageList = quotationService.companyPeriodList(pageController, quotationCompanyPeriodVo);
		List<QuotationCompanyPeriodVo> quotationCompanyPeriodVoList = new ArrayList<QuotationCompanyPeriodVo>();
		List items = pageList.getItems();
		if (items != null) {
			for (int i = 0; i < items.size(); i++) {
				Object[] item = (Object[]) items.get(i);
				QuotationCompanyPeriodVo f = new QuotationCompanyPeriodVo();
				f.setQuotationId(Long.valueOf(item[0].toString()));
				f.setQuotationName(item[1].toString());
				f.setQuotationDate(item[2].toString());
				f.setQuotationFlag((Integer) item[3]);
				f.setCompanyId((Integer) item[4]);
				f.setCompanyName((String) item[5]);
				quotationCompanyPeriodVoList.add(f);
			}
		}
		json.put("success", true);
		json.put("total", pageList.getTotalCount());
		json.put("rows", quotationCompanyPeriodVoList);
		return json.toString();
	}

	@RequestMapping(value = "/preSaveCompanyPeriod.do", method = { RequestMethod.GET })
	public ModelAndView preSaveShop() {
		/*
		 * JSONObject json = new JSONObject(); List<RoleVo> roleList = null;
		 * 
		 * try { roleList = foodService.listAllRole(); //查询所有角色信息 } catch
		 * (GenericException e) { e.printStackTrace(); }
		 */
		Map map = new HashMap();
		// map.put("rolelist", roleList);
		return new ModelAndView("/shop/addShop", map);
	}

	@RequestMapping(value = "/preDetailCompanyPeriod.do", method = { RequestMethod.GET })
	public ModelAndView preDetailCompanyPeriod(long quotationId) {

		Map map = new HashMap();
		map.put("quotationId", quotationId);
		return new ModelAndView("/supplier/raisePrice/detailRaisePricePeriod", map);
	}

	@RequestMapping(value = "/detailRaisePricePeriod.do", method = { RequestMethod.POST })
	@ResponseBody
	public String detailRaisePricePeriod(@RequestParam(required = false) String page, @RequestParam(required = false) String rows,
			QuotationCompanyPeriodVo quotationCompanyPeriodVo, HttpSession session) throws GenericException {
		JSONObject json = new JSONObject();
		if (page == null || page.equals(""))
			page = "1";
		if (rows == null || rows.equals(""))
			rows = "10";

		UserPo userInfo = (UserPo) session.getAttribute("user");
		int supId = supplierService.getSupIdByUserId(userInfo.getUserId());
		quotationCompanyPeriodVo.setSupId(supId);
		PageController pageController = new PageController(Integer.parseInt(page), Integer.parseInt(rows));
		this.pageList = quotationService.detailRaisePricePeriod(pageController, quotationCompanyPeriodVo);
		List<QuotationCompanyPeriodVo> quotationCompanyPeriodVoList = new ArrayList<QuotationCompanyPeriodVo>();
		List items = pageList.getItems();
		if (items != null) {
			for (int i = 0; i < items.size(); i++) {
				Object[] item = (Object[]) items.get(i);
				QuotationCompanyPeriodVo f = new QuotationCompanyPeriodVo();
				f.setSubId(Long.valueOf(item[0].toString()));
				f.setQuotationId(Long.valueOf(item[1].toString()));
				f.setMaterId(Integer.valueOf(item[2].toString()));
				f.setMaterValue(item[3].toString());

				f.setMaterName((String) item[4]);
				f.setUnit((String) item[5]);
				f.setSpecifications((String) item[6]);
				f.setBrands((String) item[7]);
				f.setMaterType(Integer.valueOf(item[8].toString()));
				quotationCompanyPeriodVoList.add(f);
			}
		}
		json.put("success", true);
		json.put("total", pageList.getTotalCount());
		json.put("rows", quotationCompanyPeriodVoList);
		return json.toString();
	}

	// 导入新周期报价
	@RequestMapping(value = "/importDetailCompanyPeriod.do", method = { RequestMethod.POST })
	@ResponseBody
	public String importDetailCompanyPeriod(QuotationCompanyPeriodExcelVo quotationCompanyPeriodExcelVo, HttpServletRequest request,
			HttpServletResponse response, HttpSession session) throws Exception {
		JSONObject json1 = new JSONObject();

		// 事物锁
		UserPo lgUser = (UserPo) session.getAttribute("user");
		int supId = supplierService.getSupIdByUserId(lgUser.getUserId());
		boolean lockFlag = lockTransService.lockTrans("importDetailCompanyPeriod.do", supId);
		if (!lockFlag) {
			json1.put("msg", "locked");
			json1.put("success", false);
			return json1.toString();
		}
		// 事务锁over
		try {

			MultipartFile filename = quotationCompanyPeriodExcelVo.getFilename();

			String temp = request.getSession().getServletContext().getRealPath(File.separator) + "temp"; // 临时目录
			File tempFile = new File(temp);
			if (!tempFile.exists()) {
				tempFile.mkdirs();
			}
			DiskFileUpload fu = new DiskFileUpload();
			fu.setSizeMax(10 * 1024 * 1024); // 设置允许用户上传文件大小,单位:位
			fu.setSizeThreshold(4096); // 设置最多只允许在内存中存储的数据,单位:位
			fu.setRepositoryPath(temp); // 设置一旦文件大小超过getSizeThreshold()的值时数据存放在硬盘的目录
			// 开始读取上传信息
			// int index = 0;
			if (filename == null)
				return null;

			String name = filename.getOriginalFilename();// 获取上传文件名,包括路径
			String quotationName = name.substring(name.lastIndexOf("\\") + 1);// 从全路径中提取文件名
			long size = filename.getSize();
			if ((name == null || name.equals("")) && size == 0) {
				json1.put("msg", "msg001");
				json1.put("success", false);
				return json1.toString();
			}
			InputStream in = filename.getInputStream();

			ExcelReader excelReader = new ExcelReader();
			String[] title = excelReader.readExcelTitle(in);
			// System.out.println("获得Excel表格的标题:");
			for (String s : title) {
				System.out.print(s + " ");
			}

			// 对读取Excel表格内容测试
			Map<Integer, String> map = excelReader.readExcelContent(in, "^");

			boolean flag = false;
			try {
				flag = quotationService.checkImportDetailCompanyPeriod(map);
				if (flag) {
					QuotationCompanyPeriodPo tQuotationCompanyPeriodPo = quotationService.addQuotationCompanyPeriodPo(supId,
							quotationCompanyPeriodExcelVo.getCompanyId(), quotationName);
					quotationService.importDetailCompanyPeriod(map, tQuotationCompanyPeriodPo);
				}

			} catch (Exception e) {
				json1.put("msg", quotationService.getMsg());
				json1.put("content", quotationService.getContent());

				flag = false;
			}

			if (flag) {
				json1.put("success", true);
			} else {
				json1.put("msg", quotationService.getMsg());
				json1.put("content", quotationService.getContent());

				json1.put("success", false);
			}
		} catch (Exception e) {
			json1.put("msg", "exception");
			json1.put("content", quotationService.getContent());
			json1.put("success", false);
			return json1.toString();
		} finally {
			// 解锁
			lockTransService.unlockTrans("importDetailCompanyPeriod.do", supId);
		}
		return json1.toString();

	}

	// 分货 检索客户列表
	@RequestMapping(value = "/getAllCompanyJson.do", method = { RequestMethod.POST })
	@ResponseBody
	public String getAllCompanyJson(HttpServletRequest request, HttpServletResponse response, HttpSession session, String diy) {
		JSONObject json = new JSONObject();
		json.put("success", true);
		response.setContentType("text/json;charset=UTF-8");
		try {
			String userTestValue = quotationService.getAllCompanyJson(diy);
			json.put("stringJson", userTestValue);

		} catch (GenericException e) {
			e.printStackTrace();
		}
		return json.toString();
	}

	@RequestMapping(value = "/getAllCompanyJsonForSup.do", method = { RequestMethod.POST })
	@ResponseBody
	public String getAllCompanyJsonForSup(HttpServletRequest request, HttpServletResponse response, HttpSession session, String diy) {
		JSONObject json = new JSONObject();
		json.put("success", true);
		response.setContentType("text/json;charset=UTF-8");
		try {
			UserPo userInfo = (UserPo) session.getAttribute("user");
			int supId = supplierService.getSupIdByUserId(userInfo.getUserId());
			String userTestValue = quotationService.getAllCompanyJsonForSup(diy, supId);
			json.put("stringJson", userTestValue);

		} catch (GenericException e) {
			e.printStackTrace();
		}
		return json.toString();
	}

	// 采用方案
	@RequestMapping(value = "/adoptCompanyPeriod.do", method = { RequestMethod.POST })
	@ResponseBody
	public String adoptCompanyPeriod(long quotationId, int companyId, HttpSession session) {
		JSONObject json = new JSONObject();
		json.put("success", true);

		try {
			UserPo lgUser = (UserPo) session.getAttribute("user");
			int supId = supplierService.getSupIdByUserId(lgUser.getUserId());
			boolean flag = quotationService.adoptCompanyPeriod(supId, quotationId, companyId);
			json.put("success", true);

		} catch (GenericException e) {
			e.printStackTrace();
		}
		return json.toString();
	}

	// 删除方案
	@RequestMapping(value = "/deleteCompanyPeriod.do", method = { RequestMethod.POST })
	@ResponseBody
	public String deleteCompanyPeriod(long quotationId, int companyId, HttpSession session) {
		JSONObject json = new JSONObject();
		json.put("success", true);

		try {
			quotationService.deleteCompanyPeriod(quotationId);
			json.put("success", true);

		} catch (GenericException e) {
			e.printStackTrace();
		}
		return json.toString();
	}

	// 进货报表导出
	@RequestMapping(value = "/downCompanyPeriod.do", method = { RequestMethod.POST })
	@ResponseBody
	public String downCompanyPeriod(HttpServletRequest request, HttpServletResponse response, HttpSession session1, int quotationId) {
		JSONObject json = new JSONObject();
		HttpSession session = request.getSession();
		session.setAttribute("state", null);
		// 生成提示信息，
		String codedFileName = null;
		String codedFileNameUser = null;

		OutputStream fOut = null;
		UserPo userInfo = (UserPo) session1.getAttribute("user");

		try {

			response.setContentType("application/vnd.ms-excel");

			// 进行转码，使其支持中文文件名
			// codedFileName = java.net.URLEncoder.encode("Quotation" + supId +
			// "_" + orderDate, "UTF-8");

			String quotationName = quotationService.getQuotationCompanyPeriodPo(quotationId).getQuotationName();
			codedFileName = new String(quotationName.getBytes("GBK"), "ISO8859-1");
			response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
			// response.addHeader("Content-Disposition",
			// "attachment;   filename=" + codedFileName + ".xls");
			// 产生工作簿对象
			HSSFWorkbook workbook = new HSSFWorkbook();
			// 产生工作表对象

			HSSFSheet sheet = workbook.createSheet();
			// 边框
			HSSFCellStyle setBorder = workbook.createCellStyle();
			setBorder.setBorderBottom(HSSFCellStyle.BORDER_THIN); // 下边框
			setBorder.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
			setBorder.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
			setBorder.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
			setBorder.setAlignment(HSSFCellStyle.VERTICAL_CENTER);

			int sheetIndex = 0;
			// 初始行设置
			HSSFRow rowfist = sheet.createRow((int) 0);// 创建一行
			rowfist.setHeight((short) 340);// 行高

			int totalLine = 0;

			HSSFCell cellFirst1 = rowfist.createCell(totalLine);// 创建一列
			cellFirst1.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst1.setCellValue("材料Id");
			cellFirst1.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst3 = rowfist.createCell(totalLine);// 创建一列
			cellFirst3.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst3.setCellValue("材料名");
			cellFirst3.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst4 = rowfist.createCell(totalLine);// 创建一列
			cellFirst4.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst4.setCellValue("种类");
			cellFirst4.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst5 = rowfist.createCell(totalLine);// 创建一列
			cellFirst5.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst5.setCellValue("品牌");
			cellFirst5.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst7 = rowfist.createCell(totalLine);// 创建一列
			cellFirst7.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst7.setCellValue("规格");
			cellFirst7.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst8 = rowfist.createCell(totalLine);// 创建一列
			cellFirst8.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst8.setCellValue("单位");
			cellFirst8.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			HSSFCell cellFirst9 = rowfist.createCell(totalLine);// 创建一列
			cellFirst9.setCellType(HSSFCell.CELL_TYPE_STRING);
			cellFirst9.setCellValue("单价");
			cellFirst9.setCellStyle(setBorder);
			totalLine = totalLine + 1;

			// 根据日期取得 总表数据
			List<Object[]> listTotal = quotationService.getCompanyPeriodForExcel(quotationId);
			for (int i = 0; i < listTotal.size(); i++) {

				Object[] a = listTotal.get(i);
				HSSFRow row = sheet.createRow((int) i + 1);// 创建一行
				row.setHeight((short) 340);// 行高

				int totalDateLine = 0;

				HSSFCell cell1 = row.createCell(totalDateLine);// 创建一列 材料Id
				cell1.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell1.setCellValue(a[0].toString());
				cell1.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell3 = row.createCell(totalDateLine);// 创建一列 材料品级
				cell3.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell3.setCellValue(a[1].toString());
				cell3.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell4 = row.createCell(totalDateLine);// 创建一列 供货商ID
				cell4.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell4.setCellValue(a[2].toString());
				cell4.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell5 = row.createCell(totalDateLine);// 创建一列 供货商name
				cell5.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell5.setCellValue(a[3].toString());
				cell5.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell7 = row.createCell(totalDateLine);// 创建一列 时间
				cell7.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell7.setCellValue(a[4].toString());
				cell7.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell8 = row.createCell(totalDateLine);// 创建一列 时间
				cell8.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell8.setCellValue(a[5].toString());
				cell8.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

				HSSFCell cell9 = row.createCell(totalDateLine);// 创建一列 时间
				cell9.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell9.setCellValue(a[6].toString());
				cell9.setCellStyle(setBorder);
				totalDateLine = totalDateLine + 1;

			}

			workbook.setSheetName(sheetIndex, "报价页面");

			// 总表 分店显示材料数量
			sheet.setForceFormulaRecalculation(true);
			fOut = response.getOutputStream();
			workbook.write(fOut);
		} catch (UnsupportedEncodingException e1) {
		} catch (Exception e) {
		} finally {
			try {
				fOut.flush();
				fOut.close();
			} catch (IOException e) {
				json.put("success", false);
			}
			session.setAttribute("state", "open");
		}

		json.put("success", true);
		return json.toString();
	}

	@RequestMapping(value = "/getCompanyPeriodValue.do", method = { RequestMethod.POST })
	@ResponseBody
	public String getCompanyPeriodValue(HttpSession session, HttpServletRequest request, HttpServletResponse response, int materId, long shopId) {
		JSONObject json = new JSONObject();
		json.put("success", true);
		String materCompanyPeriodValue = "0";
		UserPo userInfo = (UserPo) session.getAttribute("user");

		try {
			int supId = supplierService.getSupIdByUserId(userInfo.getUserId());
			materCompanyPeriodValue = quotationService.getCompanyPeriodValue(materId, supId, shopId);

		} catch (GenericException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		json.put("materCompanyPeriodValue", materCompanyPeriodValue);
		return json.toString();
	}

	@RequestMapping(value = "/addQuotationMaterByShopIdMaterIdForSup.do", method = { RequestMethod.POST })
	@ResponseBody
	public String addQuotationMaterByShopIdMaterIdForSup(QuotationCompanyPeriodSubVo c, HttpSession session) {
		JSONObject json = new JSONObject();
		try {

			UserPo userInfo = (UserPo) session.getAttribute("user");
			c.setSupId(supplierService.getSupIdByUserId(userInfo.getUserId()));
			boolean flag = quotationService.addQuotationMaterByShopIdMaterIdForSup(c);
			if (flag) {
				json.put("success", true);
			} else {
				json.put("success", false);
				json.put("msg", quotationService.getMsg());
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.put("success", false);
		}
		return json.toString();
	}

}
